home *** CD-ROM | disk | FTP | other *** search
- /* File "mactcp.h", Light Sockets - Copyright (C) Matt Slot, 1996 */
- /* MacTCP implementation for "Light Sockets" network abstraction library. */
-
- #ifndef __MACTCP_HEADER__
- #define __MACTCP_HEADER__
-
- #ifndef __STD_TYPES_HEADER__
- #include "stdtypes.h"
- #endif /* __STD_TYPES_HEADER__ */
-
- #ifndef __NET_STACK_HEADER__
- #include "netstack.h"
- #endif /* __NET_STACK_HEADER__ */
-
- #include <MacTCP.h>
-
- /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
- /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
- /* Preprocessor Defines */
-
- #define kMacTCPSocketBufferSize 4096
- #define kMacTCPDataBufferSize 1024
- #define kMacTCPNumParamBlocks 10
-
- /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
- /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
- /* Enum/Structure/Class Definitions */
-
- typedef struct MacTCPData {
- union {
- UDPiopb udppb;
- TCPiopb tcppb;
- } pb;
- wdsEntry wds[2];
- UInt32 dataLen;
- Byte8 dataBuff[kMacTCPDataBufferSize];
- } MacTCPData, *MacTCPDataPtr;
-
- /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
-
- typedef class MacTCPStack : public NetworkStack {
-
- public:
-
- /* Constructor/Destructor */
- MacTCPStack (SocketRef socket);
- virtual ~MacTCPStack (void);
-
-
- /* Network stack dispatch */
- virtual SocketResult DoLoad (void);
- virtual SocketResult DoUnload (void);
-
-
- /* Socket-based dispatch */
- virtual SocketResult DoCreate (void);
- virtual SocketResult DoTickle (void);
- virtual SocketResult DoDispose (void);
-
- virtual SocketResult DoBind (SocketAddressPtr reqAddress,
- SocketAddressPtr retAddress);
- virtual SocketResult DoUnbind (void);
-
-
- /* Name service dispatch */
- virtual SocketResult DoAddressResolve(Char8 *textAddress,
- SocketAddressPtr socketAddress);
- virtual SocketResult DoAddressLookup (SocketAddressPtr socketAddress,
- Char8 *textAddress);
-
- /* Datagram-based dispatch */
- virtual SocketResult DoDatagramWrite (Byte8 *dataPtr, UInt32 dataLen,
- SocketAddressPtr address);
-
- /* Stream-based dispatch */
- virtual SocketResult DoStreamServer (UInt32 sessions);
- virtual SocketResult DoStreamClient (SocketAddressPtr address);
- virtual SocketResult DoStreamWrite (Byte8 *dataPtr, UInt32 dataLen);
- virtual SocketResult DoStreamClose (Bool8 orderly);
-
-
- private:
-
- /* Private callbacks */
- static pascal void DNRComplete (struct hostInfo *hInfo,
- Bool8 *doneFlag);
- static void E2SCleanup (class MacTCPStack *stack);
- static void UDPAsyncRead (struct UDPiopb *iopb);
- static void UDPAsyncBfrRtn (struct UDPiopb *iopb);
- static void UDPSendComplete (struct UDPiopb *iopb);
-
- static UInt32 loadCount; /* Class instance counter */
- SInt16 refnum; /* MacTCP driver refnum */
- Bool8 disposing; /* Indicates cleanup in progress */
- StreamPtr stream; /* Underlying UDP/TCP stream */
- UDPIOCompletionUPP readUPP;
- UDPIOCompletionUPP bfrRtnUPP;
- UDPIOCompletionUPP sendDoneUPP;
-
- #if GENERATINGCFM || __A5__
- UInt32 homeA5; /* Globals register */
- #else
- UInt32 homeA4; /* Globals register */
- #endif
-
- Byte8 buffer[kMacTCPSocketBufferSize];
- MacTCPData dataBuffs[kMacTCPNumParamBlocks];
- UDPiopb readPB;
- QHdr freeQ;
- QHdr busyQ;
- } MacTCPStack, *MacTCPStackRef;
-
- /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
- /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
- /* Function Prototypes */
-
-
- /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
- /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
-
-
- #endif /* __MACTCP_HEADER__ */
-
-